#ifndef PGM_IO_H
#define PGM_IO_H

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#define ERROR_OK 0
#define ERROR_FAILURE 1

typedef struct _PGMData {
    int row;
    int col;
    int max_gray;
    int **matrix;
} PGMData;

int ** allocate_dynamic_matrix(int row, int col);

int deallocate_dynamic_matrix(int **matrix, int row);

PGMData * readPGM_bin(const char * file_name, PGMData * data);
PGMData * readPGM_txt(const char * file_name, PGMData * data);

int writePGM_bin(const char * filename, const PGMData * data);
int writePGM_txt(const char * filename, const PGMData * data);

#endif
